// setTimeout(function () {
//     var a = 'hello'
//     setTimeout(function () {
//         var b = 'lagou'
//         setTimeout(function () {
//             var c = 'I ♥ U'
//             console.log(a + b + c)
//         }, 10)
//     }, 10)
// }, 10)



// Promise
new Promise(function (resolve, reject) {
    setTimeout(function () {
        var a = 'hello';
        resolve(a);
    }, 10);
}).then(function (value) {
    return new Promise(function (resolve, reject) {
        setTimeout(function () {
            var b = 'lagou';
            resolve(value + b);
        }, 10);
    })
}).then(function (value) {
    return new Promise(function (resolve, reject) {
        setTimeout(function () {
            var c = 'I ♥ U';
            console.log(value + c);
        }, 10);
    })
})



// async/await
function getA() {
    return new Promise(function (resolve, reject) {
        setTimeout(function () {
            var a = 'hello';
            resolve(a);
        }, 10);
    })
}
function getB() {
    return new Promise(function (resolve, reject) {
        setTimeout(function () {
            var b = 'lagou';
            resolve(b);
        }, 10);
    })
}
function getC() {
    return new Promise(function (resolve, reject) {
        setTimeout(function () {
            var c = 'I ♥ U';
            resolve(c);
        }, 10);
    })
}
async function getResult() {
    var a = await getA();
    var b = await getB();
    var c = await getC();
    console.log(a + b + c);
}
getResult();



// Promise.all
Promise.all([
    getA(),
    getB(),
    getC(),
]).then((arr) => {
    const [a, b, c] = arr;
    console.log(a + b + c);
});


